package ans.p75;

import test.Entrance;

/**
 * #      75
 * 名称   颜色分类
 * 链接   https://leetcode-cn.com/problems/sort-colors
 * 题解   [1352](https://leetcode-cn.com/problems/sort-colors/solution)
 * 通过率 58.0%
 * 难道   中等
 */

public class Solution {
    @Entrance
    public void sortColors(int[] nums) {
        int num0 = 0, num1 = 0, num2 = 0;
        for(int i = 0; i < nums.length; i++) {
            if(nums[i] == 0) {
                nums[num2++] = 2;
                nums[num1++] = 1;
                nums[num0++] = 0;
            }else if(nums[i] == 1) {
                nums[num2++] = 2;
                nums[num1++] = 1;
            }else {
                nums[num2++] = 2;
            }
        }
    }
}